package cn.xawl.interview.thread;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @author lh
 * @date 2020/08/26 14:41:08
 **/
public enum Country {

    QI(1, "齐国"),CHU(2, "楚国"),YAN(3, "燕国"),ZHAO(4, "赵国"),WEI(5, "魏国"),HAN(6, "韩国");

    @Getter private final int index;
    @Getter private final String country;

    Country(Integer index, String country) {
        this.index = index;
        this.country = country;
    }

    /**
     * 通过index，过去国家名字
     * */

    public static String getCountryByIndex(int index) {
        Country[] countries = Country.values();
        for (Country country : countries) {
            if (country.getIndex() == index) {
                return country.getCountry();
            }
        }
        return null;
    }


}

